<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="./layui/css/layui.css">
		<script src="./layui/layui.js"></script>
		<script type="text/javascript" src="js/global.js"></script>
	</head>

	<body>
		<form class="layui-form" action="">

			<div class="layui-form-item">
				<label class="layui-form-label">文档标题</label>
				<div class="layui-input-block">
					<input name="dotitle" id="dotitle" class="layui-input" type="text" placeholder="请输入标题" autocomplete="off" lay-verify="title">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">标题描述</label>
				<div class="layui-input-block">
					<input name="dodescription" id="dodescription" class="layui-input" type="text" placeholder="请输入标题描述名" autocomplete="off" lay-verify="title">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">内容</label>
				<div class="layui-input-block">
					<input name="docontent" id="docontent" class="layui-input" type="text" placeholder="请输入内容" autocomplete="off" lay-verify="title">
				</div>
			</div>
	

  	<div class="layui-form-item" hidden>
				<label class="layui-form-label">创建人</label>
				<div class="layui-input-block">
					<input name="docjr" id="docjr" class="layui-input" type="text" placeholder="请输入创建人" autocomplete="off" lay-verify="title">
				</div>
			</div>
  
			

			<div class="layui-inline">
				<label class="layui-form-label">创建时间</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="dotime" id="dotime" placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="title">
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" type="submit" lay-filter="formDemo" lay-submit="">立即提交</button>

				</div>
			</div>

		</form>

		<script>
		
			
			layui.use(['table', 'form', 'layer', 'laydate', 'layedit'], function() {
				var table = layui.table;
				var form = layui.form;
				var layer = layui.layer;
				var $ = layui.jquery;
				var layedit = layui.layedit;
				 var laydate = layui.laydate;
				 
				 console.log(globalData.getUid())
				 var uid=$("#docjr").val(globalData.getUid())
				 
				 
				 //自定义验证规则
						form.verify({
							title: function(value,item) {
								if(value.length < 1) {
									return '不能为空！！';
								}
							}
							

						});
  
				//解决跨域
				$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
					options.xhrFields = {
						withCredentials: true
					}
				})
			
				//日期时间选择器
				laydate.render({
					elem: '#dotime',
					type: 'datetime'
				});

				form.on('submit(formDemo)', function(data) {
					var d = data.field;
					var url = globalData.server + './Document/doadd';
					$.post(url, d, function(res) {
						console.log(res);
						if(res.count > 0) {
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
						}
					}, 'json');
					return false;
				});

			});
		</script>
	</body>

</html>